﻿-- =========================================================================================================
-- Author:		MICHAEL RITACCO
-- Copyright:	2010 MEKHANO GROUP LLC
-- Version:		09/25/2010 1.0
-- =========================================================================================================
CREATE PROCEDURE [flcr].[api_device_category_type_xref_sel_lov]
@DEVICE_CAT_TYPE_XREF_ID INT = NULL
,@DEVICE_CATEGORY_ID INT = NULL
,@ACTIVE_FLG BIT = NULL
,@DEVICE_TYPE INT = NULL

AS
BEGIN TRY
  
	SELECT	A.[DEVICE_CATEGORY_TYPE_XREF_ID]
			,B.[DEVICE_CATEGORY_NAME]
			,C.[DEVICE_TYPE_NAME]
			,D.[DEVICE_TYPE_GROUP_NAME] 
	  FROM	[FLCR].[DEVICE_CATEGORY_TYPE_XREF] A
	 INNER JOIN [FLCR].[DEVICE_CATEGORY] B
		ON	A.[DEVICE_CATEGORY_ID] = B.[DEVICE_CATEGORY_ID]
	 INNER JOIN [FLCR].[DEVICE_TYPE] C
		ON	A.[DEVICE_TYPE] = C.[DEVICE_TYPE]
	 INNER JOIN [FLCR].[DEVICE_TYPE_GROUP] D
		ON	C.[DEVICE_TYPE_GROUP] = D.[DEVICE_TYPE_GROUP]
     WHERE	[DEVICE_CATEGORY_TYPE_XREF_ID] = COALESCE(@DEVICE_CAT_TYPE_XREF_ID,[DEVICE_CATEGORY_TYPE_XREF_ID])
	   AND	A.[DEVICE_CATEGORY_ID] = COALESCE(@DEVICE_CATEGORY_ID,A.[DEVICE_CATEGORY_ID])
       AND	A.[ACTIVE_FLG] = COALESCE(@ACTIVE_FLG,A.[ACTIVE_FLG])
	   AND	C.[DEVICE_TYPE] = COALESCE(@DEVICE_TYPE,C.[DEVICE_TYPE])      

END TRY
BEGIN CATCH
	EXEC [flcr].[utl_getDBError];
END CATCH
